﻿(function () {
    'use strict';

    var controllerId = 'loginController';

    angular.module('app').controller(controllerId,
        ['common', '$scope', 'loginServece', loginController]);

    function loginController(common, $scope, loginServece) {
        localStorage.clear();
        $scope.logintUser = function () {
            var userName = $scope.userName;
            var password = $scope.password;

            var boolPasswordLength = password.length < 6;
            var boolUsernameLength = userName.length < 6;

            if (boolPasswordLength) {
                alert("password must be at least 6 letters");
                return;
            }

            if (boolUsernameLength) {
                alert("username must be at least 6 letters");
                return;
            }
            else {
                loginServece.loginUser(userName, password);
            };
        };
    }
})();
